<?php

/**
 * @author Invisible Man
 * @copyright 2013
 */
function file_fix_name ($name){
    if (strlen($name) != mb_strlen($name,"UTF-8")) {
        return false;
    }    
    $name_low = strtolower($name);
    $name_fix = str_replace(" ", "_", $name_low);
    return $name_fix;
}

function file_auth_type($name, $file_type) {
    $name_fix = file_fix_name($name);
    $pos = mb_strrpos($name_fix, ".");
    $type = mb_substr($name_fix, $pos +1);
    if (!in_array($type, $file_type)) {
        return false;
    }
    return true;
}


?>